function setup() {
  JSMR.log.info("setup");
}

function Map(input, output) {
  /* We only want real words, so split on any non-word character such as
   * punctuation or white space
   */

  var data = input.value.split(/\W/); 
  for (var i in data) {
    /*  Ignore empty parts.  For example, if '...' happened in the input it
     *  would be three seperate data[.] entries, each being empty.
     */
    if(data[i].length > 0) {
      output.emit(data[i].toLowerCase(), 1);
    }
  }
}

function Reduce(input, output) {
  var sum = 0;
  for(var i in input.values) {
    sum += parseInt(input.values[i]);
  }
  output.emit(input.key, sum);
}
